package com.hw.hcit.conf;

import java.util.HashMap;

import android.app.Activity;

import com.hw.hcit.JCase;
import com.hw.hcit.JProject;
import com.hw.hcit.JProjects;
import com.hw.hcit.feature.AutoResultTest;
import com.hw.hcit.feature.ProjectTest;
import com.hw.hcit.feature.ProjectsTest;
import com.hw.hcit.feature.TPTestItem;

public class Config {

	public static JProjects PROJECTS  = null;
	public static JProject CURR_PROJECT = null;
	public static JCase CURR_CASE = null;
	public static JCtrlCallback cb = null;
	public static boolean ageingTested = false;
	
	
	public static int STEP = 0;

	public static int UI_HOLD = Integer.MAX_VALUE;
	public static int UI_PROJECTS = 1;
	public static int UI_PROJECT = 2;
	public static int UI_RESULT = 3;
	public static boolean USBOTG_SUCCESS = false;

	public static int UI_TEST_BASE = 100;
	
	public static HashMap<String, String> classMap = new HashMap<String, String>();
	
	public static  void RegsterItem(String name, String classname)
	{
		classMap.put(name, classname);
	}
	
	public static Activity GetActivity()
	{
		return (Activity)cb;
	}
	
   public static  JTestItem GetItem(String name, JCtrlCallback cb)
   {
	   JTestItem ret = null;
	   
	   if(name.equals("projects"))
	   {
		   ret = new ProjectsTest(cb);
	   }
	   else if(name.equals("project"))
	   {
		   ret = new ProjectTest(cb);
	   }
	   else if(name.equals("defautEnd"))
	   {
		   ret = new AutoResultTest();
	   }
	   else
	   {
		   String classname = classMap.get(name);
		   if(classname !=null && classname.length()>0)
		   {
			   try
			   {
				   if(classname.indexOf(".")<1)
				   {
					   classname = "com.hw.hcit.feature."+classname;
				   }
				   ret = (JTestItem) Class.forName(classname).newInstance();
			   }
			   catch(Exception e)
			   {
				   e.printStackTrace();
			   }
		   }
	   }
	   
	   
/*	   if(name.equals("LED"))
	   {
		   ret = new LEDTestItem(cb);
	   }
	   else if(name.equals("TP"))
	   {
		   ret = new TPTestItem(cb);
	   }
	   else if(name.equals("projects"))
	   {
		   ret = new ProjectsTest(cb);
	   }
	   else if(name.equals("project"))
	   {
		   ret = new ProjectTest(cb);
	   }
	   else if(name.equals("defautEnd"))
	   {
		   ret = new AutoResultTest(cb);
	   }
	*/   
	   return ret;
   }
   
   public static boolean getExsit(String s)
   {
	   boolean ret = true;
	   
	   if(s.equals("BT"))
	   {
		   //ret = ???
	   }
	   
	   return ret;
   }
   
}

